from django.db import models

from user_app.models import User
from utils.models import BaseModel

STATUS_CHOICES = [
    ('wait_good', 1),
    ('wait_pay', 2),
    ('wait_sign', 3),
    ('wait_evaluate', 4),
    ('finally', 5)
]


class OrderInfo(BaseModel):
    """订单信息"""
    order_id = models.CharField(max_length=64, primary_key=True,
                                verbose_name="订单号")
    user = models.ForeignKey(User, related_name='orders',
                             on_delete=models.PROTECT, verbose_name="下单用户")
    total_count = models.IntegerField(default=1, verbose_name="商品总数")
    total_amount = models.DecimalField(max_digits=10, decimal_places=2,
                                       blank=True,
                                       verbose_name="商品总金额")
    freight = models.DecimalField(max_digits=10, decimal_places=2, default=10,
                                  verbose_name="运费")
    pay_method = models.SmallIntegerField(default=1, verbose_name="支付方式")
    # 1-待发货，2-待支付，3-待收货，4-待评价，5-完成
    status = models.SmallIntegerField(default=1,
                                      verbose_name="订单状态")

    class Meta:
        db_table = "tb_order_info"
        verbose_name = '订单基本信息'
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.order_id
